# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Tails: The Amnesic Incognito Live System
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require_relative 'lib/tails_build_settings'

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'

Vagrant.configure("2") do |config|
  config.vm.box = 'tails-builder-amd64-jessie-20160226'
  config.vm.box_url = "http://dl.amnesia.boum.org/tails/project/vagrant/#{config.vm.box}.box"
  config.vm.box_download_checksum_type = "sha256"
  config.vm.box_download_checksum = 'a63298b7cae7cbc2ad3e2c01763a11b29ee8ac879398e007ae22857da5b2c6de'
  config.vm.provision "shell", inline: <<-EOF
    sudo http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder
  EOF
  config.vm.synced_folder '.', '/vagrant', type: '9p', readonly: true
  config.vm.synced_folder '../.git', '/amnesia.git', type: '9p', readonly: true
  config.vm.provider :libvirt do |domain|
    domain.default_prefix = config.vm.box
    domain.driver = 'kvm'
    domain.management_network_guest_ipv6 = 'no'
    domain.connect_via_ssh = false
    domain.machine_arch = 'x86_64'
    domain.machine_type = 'q35'
    domain.cpu_mode = 'host-passthrough'
    domain.emulator_path = '/usr/bin/qemu-system-x86_64'
    domain.memory = ENV['TAILS_RAM_BUILD'] ? VM_MEMORY_FOR_RAM_BUILDS :
                                             VM_MEMORY_FOR_DISK_BUILDS
    cpus = ENV['TAILS_BUILD_CPUS']
    domain.cpus = cpus unless cpus.nil?
  end
end
